<%-- 
    Document   : crearcurso
    Created on : 04-nov-2010, 9:57:22
    Author     : David y Karmele
--%>

<%@page import="java.util.ResourceBundle"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Cliente"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Cliente"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.TipoCurso"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@include file="validarusuario.jsp" %>
<div class="contenido">
<h2 align="center">Crear un nuevo curso</h2>
    <form action="guardar-curso-accion.do" method ="post" name="datos" onsubmit="return validarFormCrearCurso(this);" >
        <input type="hidden" name="aleatorioCrearCurso" value="<%=Math.random()%>" />
        <div id="submenu">
            <%@include file="menucrearcurso.jsp" %>
        </div><br>
        <div class="errordatos">
            <% if (session.getAttribute("errores") != null) {
                ResourceBundle bundle = (ResourceBundle) application.getAttribute("errores-mapeo");
                for (String i : (ArrayList<String>) session.getAttribute("errores")) {%>
                    <%=bundle.getString(i)%><br>
                <%}
                session.removeAttribute("errores");
            }%>
        </div>
        <jsp:include page="excepciones.jsp" flush="true" />
        <h4>
            <table width="100%">
                <tr>
                    <td width="22%"><font id="obligatorio">*</font>Nombre&nbsp;del&nbsp;curso:</td>
                    <td width="78%" colspan="3"><input type="text" size="50" name="curNom" title="curNom" maxlength="50" value="<%if (request.getParameter("curNom") != null) {%><%= request.getParameter("curNom")%><%}%>" onKeyUp="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"> </td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="22%"><font id="obligatorio">*</font>Tipo&nbsp;de&nbsp;curso:</td>
                    <td width="30%"><select style="width: 90%;" name="tipoCur">
                            <%ArrayList<TipoCurso> tipos = (ArrayList<TipoCurso>) request.getAttribute("listatipos");
                                        if (tipos != null) {
                                            for (TipoCurso tipo : tipos) {%>
                            <option <%if (request.getParameter("tipoCur") != null) {
                                                    if (!request.getParameter("tipoCur").trim().isEmpty() && Integer.parseInt(request.getParameter("tipoCur")) == tipo.getTipCurId()) {%> selected <% }
                                                                        }%> value="<%=tipo.getTipCurId()%>"><%=tipo.getTipCurDescr()%></option>
                            <%}
                                        }%>
                        </select></td>
                    <td width="18%">Código&nbsp;INEM:</td>
                    <td width="30%"><input type="text" style="width: 90%;" name="curCodINEM" maxlength="10" value="<%if (request.getParameter("curCodINEM") != null) {%><%= request.getParameter("curCodINEM")%><%}%>" onKeyUp="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"></td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="22%">Cliente:</td>
                    <td width="30%"><select style="width: 90%;" name="cliente">
                            <%ArrayList<Cliente> clientes = (ArrayList<Cliente>) request.getAttribute("listaclientes");
                                        if (clientes != null) {%>
                            <option value=""></option>
                            <%for (Cliente cliente : clientes) {%>
                            <option <%if (request.getParameter("cliente") != null) {
                                    if (!request.getParameter("cliente").trim().isEmpty() && Integer.parseInt(request.getParameter("cliente")) == cliente.getCliId()) {%> selected <% }
                                        }%>  value="<%=cliente.getCliId()%>"><%=cliente.getCliNom()%></option>

                            <%}
                                        }%>
                        </select></td>
                    <td width="18%">Lugar:</td>
                    <td width="30%"><select style="width: 91%;display:inline" name="lugar">
                            <%ArrayList<String> lugares = (ArrayList<String>) request.getAttribute("listalugares");
                                        if (lugares != null) {%>
                            <option value=""></option>
                            <%for (String lugar : lugares) {%>
                            <option <%if (request.getParameter("lugar") != null) {
                                    if (lugar.equals(request.getParameter("lugar"))) {%> selected <%}
                                        }%>><%=lugar%></option>
                            <%}
                                        }%>
                        </select>&nbsp;<input type="text" name="lugars" value="" maxlength="50" style="display: none;" onkeyup="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"/><a href="#" onclick="javascript:if(document.datos.lugar.style.display=='inline'){document.datos.lugar.style.display='none';document.datos.lugars.style.display='inline';}else{document.datos.lugar.style.display='inline';document.datos.lugars.style.display='none';}">Lista/Nuevo</a></td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="22%"><input class="nobordefondoblanco" type="checkbox" name="curProyector" value="true"> Proyector</td>
                    <td width="30%"><input class="nobordefondoblanco" type="checkbox" name="enviarCorreo"  value="true"> Enviar&nbsp;correo</td>
                    <td width="18%"><input class="nobordefondoblanco" type="checkbox" name="curAplazado"  value="true"> Aplazado</td>
                    <td width="30%"></td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="22%"><font id="obligatorio">*</font>Fecha&nbsp;de&nbsp;inicio:</td>
                    <td width="30%"><input type="text" name="curFchaInReal" size="8" id="fechaInicio" onClick="popUpCalendar(this,datos.curFchaInReal,'dd/mm/yyyy');" value="<%if (request.getParameter("curFchaInReal") != null) {%><%= request.getParameter("curFchaInReal")%><%}%>" readonly></td>
                    <td width="18%"><font id="obligatorio">*</font>Fecha&nbsp;de&nbsp;fin:</td>
                    <td width="30%"><input type="text" name="curFchaFinReal" size="8" id="fechaFin" onclick="popUpCalendar(this,datos.curFchaFinReal, 'dd/mm/yyyy');" value="<%if (request.getParameter("curFchaFinReal") != null) {%><%= request.getParameter("curFchaFinReal")%><%}%>" readonly></td>

                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="22%"><font id="obligatorio"></font>Hora&nbsp;de&nbsp;inicio:<br>(hh:mm)</td>
                    <td width="30%"><input type="text" name="curHoraInicio" maxlength="5" size="3" value="<%if (request.getParameter("curHoraInicio") != null) {%><%=request.getParameter("curHoraInicio")%><%}%>" onChange="if (!validarHora(this.value)) this.value='';"/></td>
                    <td width="18%"><font id="obligatorio"></font>Hora&nbsp;de&nbsp;fin:<br>(hh:mm)</td>
                    <td width="30%"><input type="text" name="curHoraFin" maxlength="5" size="3" value="<%if (request.getParameter("curHoraFin") != null) {%><%=request.getParameter("curHoraFin")%><%}%>" onChange="if (!validarHora(this.value)) this.value='';"></td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="22%">Duracion:</td>
                    <td width="30%"><input type="text" name="curDuracion" maxlength="3" size="1" value="<%if (request.getParameter("curDuracion") != null) {%><%= request.getParameter("curDuracion")%><%}else {%>0<%}%>" onKeyUp="if (!validarNumero(this.value,false,true)) this.value=borrarCaracterDeNumero(this.value);">h
                        <input type="text" name="curDuracionMinutos" maxlength="2" size="1" value="<%if (request.getParameter("curDuracionMinutos") != null) {%><%=request.getParameter("curDuracionMinutos")%><%}else {%>0<%}%>" onKeyUp="if (!validarNumero(this.value,false,true) || !validarMinutos(this.value)) this.value='';"> min </td>
                    <td width="18%">Plazo&nbsp;reserva:</td>
                    <td width="30%"><input type="text" name="curPlazoReserva" maxlength="3" size="1" value="<%if (request.getParameter("curPlazoReserva") != null) {%><%= request.getParameter("curPlazoReserva")%><%}%>" onKeyUp="if (!validarMaximo(this.value,100)) this.value='';if(!validarNumero(this.value,false,true)) this.value=borrarCaracterDeNumero(this.value);"> %</td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="22%">Faltas&nbsp;totales:</td>
                    <td width="30%"><input type="text" name="curTotalFaltas" maxlength="2" size="1" value="<%if (request.getParameter("curTotalFaltas") != null) {%><%= request.getParameter("curTotalFaltas")%><%}%>" onKeyUp="if (!validarNumero(this.value,false,true)) this.value=borrarCaracterDeNumero(this.value);"></td>
                    <td width="18%">Faltas&nbsp;al&nbsp;mes:</td>
                    <td width="30%"><input type="text" name="curFaltasMes" maxlength="2" size="1" value="<%if (request.getParameter("curFaltasMes") != null) {%><%= request.getParameter("curFaltasMes")%><%}%>" onKeyUp="if  (!validarNumero(this.value,false,true) || !validarMaximo(this.value,31)) this.value='';"></td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td  width="100%" colspan="4">Observaciones:&nbsp;(hasta&nbsp;500&nbsp;carácteres)</td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td width="100%" colspan="4"><textarea onkeydown="if(this.value.length >= 500){  alert ('Has superado el tamaño máximo permitido'); this.value=this.value.substr(0,500); return false; }" name="curObservacion" rows="3" cols="150" onkeyup="if (!validarCaracteres(this.value, true)) this.value=cadenaCorrecta(this.value);"><%if (request.getParameter("curObservacion") != null) {%><%= request.getParameter("curObservacion")%><%}%></textarea></td>
                </tr>
            </table>
        </h4>
        <div>Los&nbsp;campos&nbsp;marcados&nbsp;con&nbsp;<font id="obligatorio">*</font>&nbsp;son&nbsp;obligatorios.    </div>
    </form>
</div>
